#pragma once

// Disable warnings about invalid XML
#pragma warning(disable:4635)
#include <Awesomium/WebViewListener.h>
#pragma warning(default:4635)

#include "vcclr.h"

namespace AwesomiumDotNet
{
	ref class WebView;
	ref class JSValue;

	class WebViewListenerWrapper : public Awesomium::WebViewListener
	{
	private:
		gcroot<WebView^> _webView;

	public:
		WebViewListenerWrapper(WebView^ webView);

		void onBeginLoading(Awesomium::WebView* caller, const std::string& url, const std::wstring& frameName, int statusCode, const std::wstring& mimeType);
		void onBeginNavigation(Awesomium::WebView* caller, const std::string& url, const std::wstring& frameName);
		void onCallback(Awesomium::WebView* caller, const std::wstring& objectName, const std::wstring& callbackName, const Awesomium::JSArguments& args);
		void onChangeCursor(Awesomium::WebView* caller, Awesomium::CursorType cursor);
		void onChangeKeyboardFocus(Awesomium::WebView* caller, bool isFocused);
		void onChangeTargetURL(Awesomium::WebView* caller, const std::string& url);
		void onChangeTooltip(Awesomium::WebView* caller, const std::wstring& tooltip);
		void onDOMReady(Awesomium::WebView* caller);
		void onFinishLoading(Awesomium::WebView* caller);
		void onGetPageContents(Awesomium::WebView* caller, const std::string& url, const std::wstring& contents);
		void onOpenExternalLink(Awesomium::WebView* caller, const std::string& url, const std::wstring& source);
		void onPluginCrashed(Awesomium::WebView* caller, const std::wstring& pluginName);
		void onReceiveTitle(Awesomium::WebView* caller, const std::wstring& title, const std::wstring& frameName);
		void onRequestMove(Awesomium::WebView* caller, int x, int y);
		void onWebViewCrashed(Awesomium::WebView* caller);
		void onRequestDownload(Awesomium::WebView* caller, const std::string& url);
		void onGetScrollData(Awesomium::WebView* caller, int contentWidth, int contentHeight, int preferredWidth, int scrollX, int scrollY);
		void onRequestFileChooser(Awesomium::WebView* caller, bool selectMultipleFiles, const std::wstring& title, const std::wstring& defaultPath);
		void onJavascriptConsoleMessage(Awesomium::WebView* caller, const std::wstring& message, int lineNumber, const std::wstring& source);
	};
}
